<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page import="com.tjsinfo.tjsoa.common.DealString"%>
<%@ page import="com.tjsinfo.tjsoa.common.PaginationSupport"%>
<%@page import="com.tjsinfo.tjsoa.vote.vo.TVoteHead;"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
DealString ds = new DealString();
	PaginationSupport paginationSupport = (PaginationSupport) request.getAttribute("paginationSupport");
	List<TVoteHead> headLists = paginationSupport.getItems();
	String pageNoStr = request.getParameter("pageNo");
	if (pageNoStr == null)pageNoStr = "0";
	Integer pageNo = Integer.valueOf(pageNoStr);
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<base href="<%=basePath%>" />
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<title>粮油集团办公自动化协作平台</title>
		<link href="<%=basePath%>style/txlz7.css" rel="stylesheet" type="text/css" />
		<link href="<%=basePath%>ajaxFramework/ext-2.1/resources/css/ext-all.css" rel="stylesheet" type="text/css" />
		<script type="text/javascript" src="<%=basePath%>ajaxFramework/ext-2.1/adapter/ext/ext-base.js"></script>
		<script type="text/javascript" src="<%=basePath%>ajaxFramework/ext-2.1/ext-all.js"></script>
		<script type="text/javascript" src="<%=basePath%>ajaxFramework/ext-2.1/source/locale/ext-lang-zh_CN.js"></script>
        <script type="text/javascript" src="<%=basePath %>ajaxFramework/jQuery/jquery.js"></script>
		<script type="text/javascript" src="<%=basePath %>js/common/global/validator.js"></script>
		<script type="text/javascript" src="<%=basePath %>js/common/global/pageControl.js"></script>
		<script type="text/javascript" src="<%=basePath %>js/common/system/selectusercheck.js"></script>
		        
		<script type="text/javascript">
			function submitpages(value){
				if(value==-1){
					alert("请重新选择页码!");
					return ;
				}
				var urls=location.href;
				if(urls.indexOf('pageNo=')==-1){
					if(urls.indexOf('?')==-1){//wucan
						window.location.href=urls+'?pageNo='+value;
					}else{
						window.location.href=urls+'&pageNo='+value;
					}
				}else{
					urls=urls.substring(0,urls.indexOf('pageNo=')+7)+value;
					window.location.href=urls;
				}
			}
			
					
			
			function issue(headId){
				$.post("<%=basePath%>tjsinfo/tjsoa/vote/validate.do",{headId: headId},function(str){
					if(str=="0"){						
                        Ext.MessageBox.confirm("提示信息","您确认当前表发布?",function(btn){
			  		        if(btn == 'yes'){
			  			       msg();
						       window.location.href='<%=basePath%>tjsinfo/tjsoa/vote/headStatus.do?headId='+headId+'&status=1';
						       return;	
			  		        }
			            });
					}
					if(str=="1"){
						Ext.MessageBox.alert('提示信息', '该表还没设定表项里的子行，请先设定子行！',function(){
						    return;
						});	
					}
					if(str=="2"){
						Ext.MessageBox.alert('提示信息', '该表还没设定表项里的列，请先设定列！',function(){
						    return;
						});
					}
					if(str=="3"){
						Ext.MessageBox.alert('提示信息', '该表还没设定表项，请先设定表项！',function(){
						   return;
						});	
					}
					if(str=="4"){
						Ext.MessageBox.alert('提示信息', '该表还没设定受评人，请先设定受评人！',function(){
						   return;
						});
					}
				});
			}				
			
			function over(headId){
				$.post('<%=basePath%>tjsinfo/tjsoa/vote/unEstimatedStatus.do',{headId: headId,readId: 0},function(read){
					if(read=="1"){
                        Ext.MessageBox.confirm("提示信息","您当期还有未投票人是否投票完毕?",function(btn){
			  		        if(btn == 'yes'){
			  			       msg();
						       window.location.href='<%=basePath%>tjsinfo/tjsoa/vote/headStatus.do?headId='+headId+'&status=2';
						       return;	
			  		        }
			            });
					}else{
                        Ext.MessageBox.confirm("提示信息","您确认当前表投票完毕?",function(btn){
			  		        if(btn == 'yes'){
			  			       msg();
						       window.location.href='<%=basePath%>tjsinfo/tjsoa/vote/headStatus.do?headId='+headId+'&status=2';
						       return;	
			  		        }
			            });
					}
				});
			}		
		
			function del(headId,name){
                Ext.MessageBox.confirm("提示信息","是否删除表头: "+name+" ?",function(btn){
  		           if(btn == 'yes'){
  			          msg();
			          window.location.href='<%=basePath%>tjsinfo/tjsoa/vote/headDel.do?headId='+headId;
			          return;	
  		           }
                });
			}					
	    </script>
	</head>

	<body>
		<div id="right">
			<div class="p_011">
				<table width="100%" border="0" cellspacing="0" cellpadding="0">
					<tr>
						<td width="90%" style="padding-top: 4px;">
							<img src="<%=basePath%>images/khicon.gif" />
						</td>
						<td width="10%" style="padding-top: 4px;" valign="middle">
							<a href="<%=basePath%>tjsinfo/tjsoa/vote/toHeadForm.do">添加</a>
						</td>
					</tr>
				</table>
			</div>
			<table width="100%" border="0" cellspacing="0" cellpadding="0" height="92%">
				<tr>
					<td width="99%" valign="top" height="100%">
						<div class="contabyear">
							<table class="p_06" width="100%" border="0" cellspacing="0">
								<tr>
									<th width="10%" style="text-align: center">
										年度(年)
									</th>
									<th width="60%" style="text-align: center">
										表头名称
									</th>
									<th width="30%" style="text-align: center">
										操作
									</th>

								</tr>
								<%
							    	Iterator iterator = headLists.iterator();
							    	while(iterator.hasNext())
							    	{
							    		TVoteHead headList = (TVoteHead)iterator.next();
							    %>
								<tr>
									<td><%=headList.getYearTime() %></td>
									<td title="<%=headList.getName() %>"><%=ds.substring(headList.getName(),45)%></td>
									<td>
									    <a href="<%=basePath%>tjsinfo/tjsoa/vote/voteBrowse.do?headId=<%=headList.getId()%>"><font color="blue">预览</font></a> 
									<%
								 	    switch (headList.getStatus()) {
								 		case 0:
								    %> 
								        <a onclick="del('<%=headList.getId()%>','<%=headList.getName()%>')" style="cursor: hand"><font color="blue">删除</font></a>
								        <a href="javascript:issue('<%=headList.getId()%>');"><font color="red">发布</font></a>
									    <a href="<%=basePath%>tjsinfo/tjsoa/vote/conformationList.do?headId=<%=headList.getId()%>&status=<%=headList.getStatus()%>&parentId=0"><font color="blue">设定表项</font></a>
									    <a href="<%=basePath%>tjsinfo/tjsoa/vote/estimatedList.do?headId=<%=headList.getId()%>&status=<%=headList.getStatus()%>"><font color="blue">设定受评人</font></a>							        
								    <%
									 	break;
									    case 1:
									%> 
									    <a href="javascript:over('<%=headList.getId()%>');"><font color="red">投票完毕</font></a>
									    <a href="<%=basePath%>tjsinfo/tjsoa/vote/unEstimatedStatus.do?headId=<%=headList.getId()%>"><font color="blue">查看未投票人</font></a>
									    <a href="<%=basePath%>tjsinfo/tjsoa/vote/conformationList.do?headId=<%=headList.getId()%>&status=<%=headList.getStatus()%>&parentId=0"><font color="blue">查看表项</font></a>
									    <a href="<%=basePath%>tjsinfo/tjsoa/vote/estimatedList.do?headId=<%=headList.getId()%>&status=<%=headList.getStatus()%>"><font color="blue">查看受评人</font></a>								    
									<%
									 	break;
									 	case 2:
									%> 
									    <a href="<%=basePath%>tjsinfo/tjsoa/vote/conformationList.do?headId=<%=headList.getId()%>&status=<%=headList.getStatus()%>&parentId=0"><font color="blue">查看表项</font></a>
									    <a href="<%=basePath%>tjsinfo/tjsoa/vote/estimatedList.do?headId=<%=headList.getId()%>&status=<%=headList.getStatus()%>"><font color="blue">查看受评人</font></a>
									<%
									 	break;
									 	}
									%> 		
									</td>
								</tr>
								<%
							    	}
							    %>
								<tr align="center">
									<td colspan="7">
										<div class="page">
											共<%=paginationSupport.getTotalCount()%>条,共<%=paginationSupport.getPageCount()%>页&nbsp;&nbsp;
											当前为第<%=pageNo + 1%>页&nbsp;&nbsp;
											<%
												if (paginationSupport.getStartIndex() > 1) {
											%>
											<a onclick="submitpages('<%=pageNo - 1%>')" style="cursor: hand">上一页</a>
											<%
												}
											%>
											<%
												if (paginationSupport.getStartIndex()
														+ paginationSupport.getPageSize() < paginationSupport
														.getTotalCount()) {
											%>
											<a onclick="submitpages('<%=pageNo + 1%>')" style="cursor: hand">下一页</a>
											<%
												}
											%>
											&nbsp;&nbsp; 跳转到

											<select name="selectPage" id="selectPage"
												onchange="submitpages(this.value)">
												<option value="0">
													--跳转--
												</option>
												<%
													for (int pi = 0; pi < paginationSupport.getPageCount(); pi++) {
												%>
												<option value="<%=pi%>"><%=pi + 1%></option>
												<%
													}
												%>
											</select>
											页

										</div>
									</td>
								</tr>
							</table>
						</div>
					</td>
				</tr>
			</table>
		</div>
	</body>
</html>
